import service from "@/utils/request";

export function getAllCourse() {
  return service({
    url: `/course/get`,
    method: "get",
  });
}

export function getCourse(pageNum: number, pageSize: number) {
  return service({
    url: `/course/get/${pageNum}/${pageSize}`,
    method: "get",
  });
}

export function getCourseById(id: string) {
  return service({
    url: `/course/authSearch/${id}`,
    method: "get",
  });
}

export function addCourse(params: object) {
  return service({
    url: `/course/add`,
    method: "post",
    params,
  });
}

export function editCourse(id: string, params: object) {
  return service({
    url: `/course/update/${id}`,
    method: "put",
    params,
  });
}

export function deleteCourse(id: string) {
  return service({
    url: `/course/delete/${id}`,
    method: "delete",
  });
}

export function searchCourseReq(searchText:string, pageNum:number, pageSize:number) {
  return service({
    url: `/course/search/{name}/${pageNum}/${pageSize}?name=${searchText}`,
    method: "get",
  });
}

//视频相关
export function addVideo(params: object) {
  return service({
    url: `/course_video/add`,
    method: "post",
    data: params,
  });
}

export function getVideo(id: string) {
  return service({
    url: `/course_video/get/${id}`,
    method: "get",
  });
}

export function editVideo(id: string, params: object) {
  return service({
    url: `/course_video/update/${id}`,
    method: "put",
    data: params,
  });
}

export function deleteVideo(id: string) {
  return service({
    url: `/course_video/delete/${id}`,
    method: "delete",
  });
}

// 通过id获取高校
export function getUnivById(id: string) {
  return service({
    url: `/orgs/univ/auth/${id}`,
    method: "get",
  });
}

export function getUnivByName(schoolname: string) {
  return service({
    url: `/orgs/univ/searchUnivByUnivNameNoPage?schoolname=${schoolname}`,
    method: "get",
  });
}

// 获取所有高校
export function getUniv() {
  return service({
    url: `/orgs/univ/1/10`,
    method: "get",
  });
}

// 获取课程排名
export function getCourseRange() {
  return service({
    url: `/course/sortByScore/1/10`,
    method: "get",
  });
}
